import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // 返回每个隐藏的菜单项
  SelectView(IconData icon, String text, String id) {
    return new PopupMenuItem<String>(
        value: id,
        child: new Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            new Icon(icon, color: Colors.blue),
            new Text(text),
          ],
        ));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '第二个flutter',
      home: Scaffold(
        appBar: AppBar(
          // title: Text('第二个flutter'),
          title: Container(
            alignment: Alignment.center,
            // color: Colors.greenAccent,
            width: 180.0,
            height: 30.0,
            decoration: BoxDecoration(
              border: Border.all(width: 1.0,color: Colors.orange),
              borderRadius: BorderRadius.circular(30.0),
            ),
            child: Row(
              children: <Widget>[
                FlatButton(
                  child: Text('已完成'),
                  onPressed: () {},
                ),
                FlatButton(
                  child: Text('未完成'),
                  onPressed: () {},
                )
              ],
            ),
          ),
          centerTitle: true,
          leading: Icon(Icons.home),
          actions: <Widget>[
            // IconButton(
            //   icon: Icon(Icons.add_alarm),
            //   tooltip: 'Add Alarm',
            //   onPressed: () => {},
            // ),
            PopupMenuButton(
              itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
                this.SelectView(Icons.message, '发起群聊', 'A'),
                this.SelectView(Icons.group_add, '添加服务', 'B'),
                this.SelectView(Icons.cast_connected, '扫一扫码', 'C'),
              ],
              onSelected: (String action) {
                // 点击选项的时候
                switch (action) {
                  case 'A':
                    break;
                  case 'B':
                    break;
                  case 'C':
                    break;
                }
              },
            )
          ],
        ),
        body: Center(
          child: Container(
            width: 400.0,
            height: 300.0,
            // color: Colors.lightBlue,
            alignment: Alignment.topLeft,
            margin: const EdgeInsets.all(10.0),
            padding: const EdgeInsets.all(20.0),
            decoration: BoxDecoration(
              gradient: const LinearGradient(
                colors: [Colors.red, Colors.blue, Colors.green],
              ),
              border: Border.all(width: 2.0, color: Colors.pink),
            ),
            // child: Text(
            //   '这个是一段很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很很长的文字 ',
            //   textAlign: TextAlign.center,
            //   maxLines: 1,
            //   overflow: TextOverflow.ellipsis,
            //   style: TextStyle(
            //     color: Colors.pinkAccent,
            //     fontSize: 20.0,
            //     decoration: TextDecoration.underline,
            //     decorationStyle: TextDecorationStyle.wavy,
            //   ),
            // ),
            child: new Image.network(
              'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575621718931&di=ad56bc0446ee8883fdb02c4eb9e0dc65&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fb8a2f3cb90ebfdcc8f432e55137d8008d8e0b53c656d-LYlEC1_fw658',
              // scale: 1.0,
              // fit: BoxFit.cover,
              // color: Colors.lightBlue,
              // colorBlendMode: BlendMode.darken,
              repeat: ImageRepeat.repeat,
            ),
          ),
        ),
      ),
    );
  }
}
